home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / util1 / yk211src.lha / Yak_2.11_Src / Icon.c < prev    next >
C/C++ Source or Header  |  1995-10-18  |  3KB  |  128 lines

  1. /*
  2.  *  Routines dealing with processing of Yak's icon
  3.  *  (be they for tooltypes or AppIcon purposes).
  4.  *  
  5.  *  MWS, Tuesday 13-Oct-92
  6.  */
  7. #include <proto/exec.h>
  8. #include <proto/dos.h>
  9. #include <proto/wb.h>
  10. #include <proto/icon.h>
  11.  
  12. #include <exec/types.h>
  13. #include <exec/ports.h>
  14. #include <exec/memory.h>
  15. #include <dos/dos.h>
  16. #include <workbench/startup.h>
  17. #include <workbench/workbench.h>
  18. #include <string.h>
  19.  
  20. #include "icon.h"
  21.  
  22. struct MsgPort *AppMsgPort=NULL;
  23. ULONG           appsigflag=0L;
  24.  
  25. static struct DiskObject *diskobj;
  26.  
  27. __regargs BOOL
  28. GetOurIcon(STRPTR name)
  29. {
  30.     if (name)
  31.     {
  32.         /* Get Disk Object */
  33.         diskobj = GetDiskObject(name);
  34.     }
  35.  
  36.     return (BOOL)(diskobj ? TRUE : FALSE);
  37. }
  38.  
  39. /* can cope with multiple calls */
  40. void
  41. FreeOurIcon()
  42. {
  43.         if (diskobj)
  44.         {
  45.                 FreeDiskObject(diskobj);
  46.                 diskobj = NULL;
  47.         }
  48. }
  49.  
  50. /* like ArgString() */
  51. __regargs char *
  52. TTString(char *name, char *def)
  53. {
  54.         char *what;
  55.         if (diskobj)
  56.                 if (what = FindToolType(diskobj->do_ToolTypes, name))
  57.                         return what;
  58.         return def;
  59. }
  60.  
  61. /* like ArgInt() */
  62. __regargs LONG
  63. TTInt(char *name, LONG def)
  64. {
  65.         char *what;
  66.         if (diskobj)
  67.                 if (what = FindToolType(diskobj->do_ToolTypes, name))
  68.                         StrToLong(what, &def);
  69.         return def;
  70. }
  71.  
  72. /* simple extension to ArgXXX routines */
  73. __regargs BOOL
  74. TTBool(char *name, BOOL def)
  75. {
  76.         char    *s;
  77.  
  78.         s = TTString(name, def ? "YES" : "NO");
  79.  
  80.         return  (BOOL)(((strcmp(s, "YES") == 0) ||
  81.                         (strcmp(s, "TRUE") == 0) ||
  82.                         (strcmp(s, "ON") == 0)) ? TRUE : FALSE);
  83. }
  84.  
  85.  
  86. #ifndef PREFS
  87.  
  88. static struct AppIcon *appicon;
  89.  
  90. /* create our AppIcon */
  91. __regargs BOOL
  92. MakeOurAppIcon(char *name)
  93. {
  94.         if (diskobj)
  95.                 if (AppMsgPort = CreateMsgPort())
  96.                 {
  97.                         diskobj->do_CurrentX = TTInt("ICONXPOS", NO_ICON_POSITION);
  98.                         diskobj->do_CurrentY = TTInt("ICONYPOS", NO_ICON_POSITION);
  99.                         if (appicon = AddAppIconA(0, 0L, name, AppMsgPort, 0L, diskobj, 0L))
  100.                         {
  101.                                 appsigflag = 1 << AppMsgPort->mp_SigBit;
  102.                                 return TRUE;
  103.                         }
  104.                         else DeleteMsgPort(AppMsgPort);
  105.                 }
  106.         return FALSE;
  107. }
  108.  
  109. /* bye bye icon... */
  110. void
  111. RemoveOurAppIcon()
  112. {
  113.         if (appicon)    RemoveAppIcon(appicon);
  114.         if (AppMsgPort) DeleteMsgPort(AppMsgPort);
  115. }
  116.  
  117. #endif
  118.  
  119.  
  120. /* just clear the port */
  121. void
  122. ClearAppMsgPort()
  123. {
  124.         struct Message *msg;
  125.         while (msg = GetMsg(AppMsgPort))
  126.                 ReplyMsg(msg);
  127. }
  128.